package org.pook.address.dao;


import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.pook.address.JpaTemplate;
import org.pook.address.dao.handler.ProvinceHandler;

import org.pook.address.persistance.HibernateUtil;

public class ProvinceDAO extends JpaTemplate implements ProvinceHandler{

	private static Logger logger = Logger.getLogger(ProvinceDAO.class);
	
	public<T> List<T> findAll(){		
		Session session =  HibernateUtil.getSessionFactory().openSession();		
		List<T> l = new ArrayList<T>();
		try{
			Query q = session.getNamedQuery("findAll");
			l = (List<T>)q.list();
		}catch (Exception e) {
			logger.error(e.getMessage());
		}
		return l;
	}	
}